'nDrawExts, by Nobuyuki (nobu@subsoap.com).  No warranties implied, use at your own risk

'Hacking this in so stuff compiles in other langs
#If TARGET="glfw" Then
Import "native/nDrawExts.${TARGET}.${LANG}"
#End 

Import mojo

Extern	
	Class DrawExts = "nDrawExts"
		Function Cls:Int(r:Float, g:Float, b:Float, a:Float)
		Function SetBlend:Int(blend:Int)
		Function SetLogicOp:Int(logicop:Int)
		Function GetAlphaThreshold:Float()
		Function SetAlphaThreshold:Int(threshold:Float)
		
		Function EnableStencil:Int()
		Function DisableStencil:Int()
		Function ClearStencil:Int()
		Function DrawToStencil:Int(enabled:Bool)
	End Class
	
Public

'Consts
	Const BLEND_ALPHA = 0
	Const BLEND_ADD = 1
	Const BLEND_SOFT_ADD = 2
	Const BLEND_MULTIPLY = 3
	Const BLEND_INVERT = 4

	Const LOGICOP_DISABLE = 0
	Const LOGICOP_COPY_INVERTED = 1
	Const LOGICOP_INVERT = 2
	Const LOGICOP_AND = 3
	Const LOGICOP_NAND = 4
	Const LOGICOP_OR = 5
	Const LOGICOP_NOR = 6
	Const LOGICOP_XOR = 7
	Const LOGICOP_EQUIVALENT = 8
	Const LOGICOP_AND_REVERSE = 9
	Const LOGICOP_AND_INVERTED = 10
	Const LOGICOP_OR_REVERSE = 11
	Const LOGICOP_OR_INVERTED = 12
	
	
'Make the DrawExts class functions available everywhere	
Function Cls2:Int(r:Float = 0, g:Float = 0, b:Float = 0, a:Float = 1)
	Return DrawExts.Cls(r, g, b, a)
End Function

Function SetBlend2:Int(blend:Int)
	Return DrawExts.SetBlend(blend)
End Function

Function SetLogicOp:Int(logicop:Int)
	Return DrawExts.SetLogicOp(logicop)
End Function

Function GetAlphaThreshold:Float()
	Return DrawExts.GetAlphaThreshold()
End Function

'Summary:  Sets the clipping threshold for all objects drawn in this loop utilizing LogicOps
Function SetAlphaThreshold:Int(threshold:Float)
	Return DrawExts.SetAlphaThreshold(threshold)
End Function

Function EnableStencil:Int()
	Return DrawExts.EnableStencil()
End Function

Function DisableStencil:Int()
	Return DrawExts.DisableStencil()
End Function

Function ClearStencil:Int()
	Return DrawExts.ClearStencil()
End Function

Function DrawToStencil:Int(enabled:Bool)
	Return DrawExts.DrawToStencil(enabled)
End Function